package com.kaisa.activity.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.kaisa.activity.BaseApp;
import com.kaisa.activity.R;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * 签证
 */
public class VisaActivity extends AppCompatActivity {
    @ViewInject(R.id.tv_visa_all)
    private TextView allTV;

    private String contryId;
    private String contry;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_visa);
        x.view().inject(this);
    }

    public void click(View v) {
        switch (v.getId()) {
            case R.id.iv_visa_back:
                this.finish();
                break;
            case R.id.ll_visa_all:
                Intent intent = new Intent(this,CountryActivity.class);
                startActivityForResult(intent,111);
                break;
            case R.id.tv_visa_search:
                String all = allTV.getText().toString();
                if (all.equals("全部")) {
                    BaseApp.getInstance().toastShow("请选择签证国家");
                } else {
                    Intent intent1 = new Intent(this,VisaListActivty.class);
                    intent1.putExtra("contryId",contryId);
                    startActivity(intent1);
                }
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 111) {
            contryId = data.getStringExtra("CountryID");
            contry = data.getStringExtra("Country");
            allTV.setText(contry);
        }
    }
}
